Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Importing "@terra-money/terra.js" throws Uncaught TypeError (Failed to resolve module specifier)

I want to work with this sample code from the Terra.js repo that I put in a file called terra-test.js:

import { LCDClient, Coin } from '@terra-money/terra.js';

// connect to bombay testnet
const terra = new LCDClient({
  URL: 'https://bombay-lcd.terra.dev',
  chainID: 'bombay-12',
});

// To use LocalTerra
// const terra = new LCDClient({
//   URL: 'http://localhost:1317',
//   chainID: 'localterra'
// });

// get the current swap rate from 1 TerraUSD to TerraKRW
const offerCoin = new Coin('uusd', '1000000');
terra.market.swapRate(offerCoin, 'ukrw').then(c => {
  console.log(`${offerCoin.toString()} can be swapped for ${c.toString()}`);
});

But when I want to call the script functions via index.html

<html>
<head>
<title>Terra.js Test</title>
</head>
<body>
<script type="module" src="terra-test.js"></script>
</body>
</html>

... I get this error:

Uncaught TypeError: Failed to resolve module specifier "@terra-money/terra.js". Relative references must start with either "/", "./", or "../".

Can somebody point me in the right direction? Thanks a lot!

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Have you installed the module through npm package manager? npm install @terra-money/terra.js

about 4 years ago · Santiago Trujillo Denunciar

0

If you just want to get experience with the TerraJS example you shared then run it from the command line with NodeJS (after npm installing the modules of course)

There are many challenges in the history of the “latest” JavaScript running in the browser versus NodeJS running JavaScript from command line or as a server. The largest challenge is modules, imports, dependencies and packaging.

All user interface examples I’ve worked using TerraJS have used React and the create-react-app or even NextJS. Which use Babel and Webpack to package Node Modules to work in the browser (ex. working from index.html, especially when there are dependencies on dependencies in the module). Off topic but related, I have recently been trying to work with another project (not Terra related) that was done with browserfy which is yet another earlier project to try to help with packaging modules and allow them to work in the browser.

My advice would be to embrace React for your TerraJS frontend and user interface development. And embrace NodeJS for just working with TerraJS Library directly.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda